package dev.touchswipe.shared.touchLib
{
	import flash.events.TouchEvent;
	import flash.geom.Point;

	public class TouchPoint
	{		
		public function TouchPoint(event:TouchEvent)
		{
			_start=new Point(event.stageX,event.stageY);
			_current=new Point(event.stageX,event.stageY);
			_touchPointID=event.touchPointID;
		}
		
		private var _touchPointID:int;
		public function get touchPointID():int{
			return _touchPointID;
		}
		
		private var _start:Point=new Point();

		public function get start():Point{
			return _start.clone();
		}

		private var _current:Point=new Point();
		public function get current():Point{
			return _current.clone();
		}

		public function get delta():Point{
			return _current.subtract(_start);
		}
		
		private var _currentDelta:Point=new Point();
		public function get currentDelta():Point{
			return _currentDelta.clone();
		}
		
		public function update(event:TouchEvent):void{
			if(event.touchPointID==_touchPointID){
				_currentDelta=new Point(event.stageX,event.stageY).subtract(_current);
				_current=new Point(event.stageX,event.stageY);
			}
		}
	}
}